﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace WPTrek.Gui.Controls
{
    /// <summary>
    /// Interaction logic for HoneycombCell.xaml
    /// </summary>
    public partial class HoneycombCell : UserControl, IHoneycombCell
    {
        public HoneycombCell(int row, int column)
        {
            InitializeComponent();

            Row = row;
            Column = column;

            Draw();
        }

        #region IHoneycombCell Members

        public int Row { get; private set; }

        public int Column { get; private set; }

        #endregion

        private void Draw()
        {
            PointCollection collection = new PointCollection();
            collection.Add(new Point(0, 0.5));
            collection.Add(new Point(0.25, 0));
            collection.Add(new Point(0.75, 0));
            collection.Add(new Point(1, 0.5));
            collection.Add(new Point(0.75, 1));
            collection.Add(new Point(0.25, 1));

            Polygon polygon = new Polygon();
            polygon.Points = collection;
            polygon.Fill = Brushes.Gold;
            polygon.Stroke = Brushes.Black;
            polygon.StrokeThickness = .5;
            polygon.UseLayoutRounding = true;
            polygon.Stretch = Stretch.Fill;

            TextBlock text = new TextBlock()
            {
                Text = String.Format("{0},{1}", Row, Column),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            LayoutRoot.Children.Add(polygon);
            LayoutRoot.Children.Add(text);
        }
    }
}
